/*
 * Player.java
 *
 * Created on 8 de noviembre de 2007, 02:21 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.sun.demo.jpa;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

/**
 * Entity class Player
 * 
 * @author DSILVA
 */
@Entity
public class Player implements Serializable {

    @ManyToOne
    @JoinColumn(columnDefinition="int") //esto es para que funcione con firebird
    private Team team;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(columnDefinition="int") //esto es para que funcione con firebird
    private Long id;
    
    /** Creates a new instance of Player */
    public Player() {
    }

    /**
     * Gets the id of this Player.
     * @return the id
     */
    public Long getId() {
        return this.id;
    }

    /**
     * Sets the id of this Player to the specified value.
     * @param id the new id
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * Returns a hash code value for the object.  This implementation computes 
     * a hash code value based on the id fields in this object.
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    /**
     * Determines whether another object is equal to this Player.  The result is 
     * <code>true</code> if and only if the argument is not null and is a Player object that 
     * has the same id field values as this object.
     * @param object the reference object with which to compare
     * @return <code>true</code> if this object is the same as the argument;
     * <code>false</code> otherwise.
     */
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Player)) {
            return false;
        }
        Player other = (Player)object;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
        return true;
    }

    /**
     * Returns a string representation of the object.  This implementation constructs 
     * that representation based on the id fields.
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "com.sun.demo.jpa.Player[id=" + id + "]";
    }

    /**
     * Holds value of property lastName.
     */
    private String lastName;

    /**
     * Getter for property lastName.
     * @return Value of property lastName.
     */
    public String getLastName() {
        return this.lastName;
    }

    /**
     * Setter for property lastName.
     * @param lastName New value of property lastName.
     */
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    /**
     * Holds value of property firstName.
     */
    private String firstName;

    /**
     * Getter for property firstName.
     * @return Value of property firstName.
     */
    public String getFirstName() {
        return this.firstName;
    }

    /**
     * Setter for property firstName.
     * @param firstName New value of property firstName.
     */
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    /**
     * Holds value of property jerseyNumber.
     */
    @Column(columnDefinition="int") //esto es para que funcione con firebird
    private int jerseyNumber;

    /**
     * Getter for property jerseyNumber.
     * @return Value of property jerseyNumber.
     */
    public int getJerseyNumber() {
        return this.jerseyNumber;
    }

    /**
     * Setter for property jerseyNumber.
     * @param jerseyNumber New value of property jerseyNumber.
     */
    public void setJerseyNumber(int jerseyNumber) {
        this.jerseyNumber = jerseyNumber;
    }

    /**
     * Holds value of property lastSpokenWords.
     */
    @Transient
    private String lastSpokenWords;

    /**
     * Getter for property lastSpokenWords.
     * @return Value of property lastSpokenWords.
     */
    public String getLastSpokenWords() {
        return this.lastSpokenWords;
    }

    /**
     * Setter for property lastSpokenWords.
     * @param lastSpokenWords New value of property lastSpokenWords.
     */
    public void setLastSpokenWords(String lastSpokenWords) {
        this.lastSpokenWords = lastSpokenWords;
    }

    public void setTeam(Team team) {
        this.team=team;
    }

    public Player(String lastName, String firstName, int jerseyNumber, String lastSpokenWords) {
        this.lastName=lastName;
        this.firstName=firstName;
        this.jerseyNumber=jerseyNumber;
        this.lastSpokenWords=lastSpokenWords;
    }
    
}
